from pymediainfo import MediaInfo
import json
from pprint import pprint
media_info = MediaInfo.parse(r"C:\Users\Administrator\Documents\WeChat Files\wxid_hs5nl9euy3un21\FileStorage\Video\2020-08\10c26d15b203ff9d45d55cdb10a29e2e_4.mp4")
# json 格式返回
# mi = MediaInfo.parse("input.mkv",output="JSON")

for track in media_info.tracks:
    if track.track_type == "Video":
        i = track.to_data()
        print(i)
        print(round(i["bit_rate"]/1000), "K")
        print(i["format"])
        print(i["format_profile"])
        print(i["width"])
        print(i["height"])

    elif track.track_type == "Audio":
        continue
        print("Track data:")
        pprint(track.to_data())
